<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<h2>用户中心</h2>
<form action="upload.php" method="post" enctype="multipart/form-data">
    请选择头像
    <input type="file" name="file" id="file" multiple="multiple">
    <br />
    <img src="" id="showImg">
    <input type="submit" value="提交"/>
</form>
</body>
<script type="text/javascript">
    var fileObj =document.getElementById('file');
    function showImg(){
        var files = fileObj['files'];
        var URL = window.URL || window.webkitURL;
        var imgURL = URL.createObjectURL(files[0]);
        document.getElementById('showImg').src = imgURL;
    }
    onload = function(){
        console.log(fileObj);
        fileObj.onchange = showImg;
    }
</script>
</html>
